package com.systop.mapper;

import com.systop.pojo.Comment;
import com.systop.pojo.Goods;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Mapper
@Component
public interface CommentMapper {
    //评论
    @Insert("insert into comment (comment_goods_id,comment_user_id,comment_content,comment_times)values(#{comment_goods_id},#{comment_user_id},#{comment_content},#{comment_times})")
    Integer addComment(Comment comment);
    //根据商品id查看评论
    @Select("select * from comment where comment_goods_id = #{comment_goods_id}")
    List<Comment> selCommentByid(Integer comment_goods_id);
    //用户查看自己给商品的评论（根据用户id查询消息）
    @Select("select * from comment where comment_user_id = #{comment_user_id}")
    List<Comment> selCommentByUserId(Integer comment_user_id);
    //评论表和商品表联合查询
    @Select("select * from comment INNER JOIN goods on comment.comment_goods_id = goods.goods_id AND `comment`.comment_goods_id = #{comment_goods_id}")
    List selCommentAndGoods(Integer comment_goods_id);
}
